1. Field of the Invention
The presented invention relates to a data compression system and a data compression method, and more particularly to a backward compression system and a backward compression method.
2. Description of the Related Art
A complicated system-on-chip (SoC), as shown in FIG. 1, includes active devices such as a microprocessor 10, a digital signal processor 11, and a direct memory accessor 14, and passive devices such as a hardware accelerator 15, an on-chip memory 12, and an external output interface 13. These devices are connected with an on-chip bus 18 to communicate with each other.
Since the on-chip operations are complicated, it is important to learn about the chip's internal operations in order to debug and analyze the chip performance. The most intuitive approach would be to connect interested signals to the chip output pins. However, since a large number of signals need to be observed and chip pins are limited, this approach is generally impractical.
In view of the above, a commonly used method is to place a real-time tracer 16 in a chip to capture signals in real time and store the captured signals in the limited spaced on-chip trace memory 17. After a tracing finishes, a decompression process is performed by the external software in an off-line manner to recover the signals. As the memory space is limited, in a related conventional method a compression function is added to the real-time tracer to increase the volume of traced information in the limited space.
In US Patent Publication No. 2004/0103399 and No. 2007/0094645, program addresses of a microprocessor are compressed. Specifically, a complete address is first recorded, and then only the difference between subsequent data and the complete data need to be recorded. Furthermore, in US Patent Publication No. 2006/0212761 and No. 2003/0126358, a memory is used for compression. Specifically, if the input data is not found in the memory, complete input data needs to be recorded and input to memory; and if the input data is found in memory, only a serial number of the data in the memory needs to be recorded to achieve compression.
The above compression method is performed based on data relationship. First, complete data is stored, and then only the relationship between subsequent data and the complete data needs to be recorded. Since the Relationship, for example, a difference or serial number, requires little storage space, the purpose of compression is achieved. Taking Table 1 as an example, an instruction address appears in a sequence of t to (t+4), and each instruction occupies 32 bits. According to a data difference compression method, the data 0×80000234 at a time point t is recorded as complete data, a difference of +0×4 between the data at a time point (t+1) and the data at the time point t is recorded, a difference of +0×4 between the data at a time point (t+2) and the data at the time point (t+1) is recorded, and data at time points (t+3) and (t+4) are processed in the same manner. As the difference only occupies 4 bits, memory space is conserved.
TABLE 1Required bitCompressedRequired bitTimeOriginal datanumberdatanumbert0x80000234320x8000023432t + 10x8000023832+0x44t + 20x8000023C32+0x44t + 30x8000024032+0x44t + 40x8000024432+0x44
However, the conventional compression method has disadvantages. When the complete data is lost, the related data based on the complete data can no longer be recovered. For example, if the data at the time point t in Table 1 is lost, none of the data at the time points (t+2) to (t+5) compressed based on the relationship with the complete data can be recovered. This restriction prevents memory with limited storage capacity from being circularly utilized. Moreover, in order to circularly utilize the memory, the oldest data must be replaced by the latest data. Memory is cleared to re-trace the compressed data, which causes the traced data to be discontinuous.
In a complicated system, it is critical for system debugging to trace data continuously, as it is difficult to predict when the system fails, and it is impossible to preset a time to start tracing and recording system signals. Therefore, the optimal method is to record the system signals continuously and maintain the currently recorded system signals as the latest data under a limited memory space. Thus, when an error occurs, the system signals prior to the error can be completely recovered for diagnosis.
Although the aforementioned conventional method can be realized by using circular memory without compression, the data volume of system signals is enormous, and the number of signals that can be traced is greatly reduced if the data is not compressed. Therefore, there is a need for an innovative and inventive data compression system and data compression method to solve the above problems.